package org.mockito.learningtests;

import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.mockito.InOrder;

import android.test.AndroidTestCase;

public class InteractionTests extends AndroidTestCase {

	private SimpleTestClass classUnderTest;

	public void setUp() throws Exception {
		classUnderTest = mock(SimpleTestClass.class);
	}

	public void testSimpleInteraction() {
		classUnderTest.getString();
		verify(classUnderTest).getString();
	}

	public void testSimpleInteractionTwice() {
		classUnderTest.getString();
		classUnderTest.getString();
		verify(classUnderTest, times(2)).getString();
	}

	public void testMethodsCalls() {
		classUnderTest.getString();
		classUnderTest.getInteger();

		verify(classUnderTest).getString();
		verify(classUnderTest).getInteger();
	}

	public void testVerifyInOrder() {
		InOrder inOrder = inOrder(classUnderTest);

		classUnderTest.getString();
		classUnderTest.getInteger();

		inOrder.verify(classUnderTest).getString();
		inOrder.verify(classUnderTest).getInteger();
	}

}
